package com.sc.VenusQueryBeta.adapter.home;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.api.Host;
import com.sc.VenusQueryBeta.model.bean.home.HomeBannerBean;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * Created by Administrator on 10/10/2018.
 * 首页banner适配器
 */

public class BannerViewHolderAdapter implements MZViewHolder<HomeBannerBean.DataBean> {

    private View view;
    private ImageView mImageView;
    private Context context;

    @Override
    public View createView(Context context) {
        // 返回页面布局
        this.context = context;
        view = LayoutInflater.from(context).inflate(R.layout.banner_item, null);
        mImageView = view.findViewById(R.id.banner_image);
        return view;
    }

    @Override
    public void onBind(Context context, int i, HomeBannerBean.DataBean dataBean) {
        LogUtils.e("url="+dataBean.getImageUrl());
        Glide.with(context).load(Host.HostImg+dataBean.getImageUrl()).diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.load_error).into(mImageView);
    }
}
